/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

/**
 * 现有代理区域
 *  */
import React, { PureComponent } from "react";
import { connect } from "dva";
import { Spin, message } from "antd";
import styles from "../style.less";

@connect(({ loading, setup }) => ({
  setup,
  loading: loading.effects["setup/getbrandList"]
}))
export default class Home extends PureComponent {
  state = {
    spin: null
  };

  componentDidMount = () => {
    const { dispatch } = this.props;
    dispatch({
      type: "setup/getbrandList",
      payload: {},
      then: () => {
        this.setState({
          spin: "1"
        });
      }
    });
  };

  render() {
    const { spin } = this.state;
    const { setup } = this.props;
    const { list } = setup || [];
    return (
      <div>
        <h2>现有代理区域</h2>
        {spin ? (
          <div className={styles.address}>
            {
              list == "" ? (
                <span>暂无数据</span>
              ) : (
                <div>
                  {list.map(({ agency_area }) => (
                    <div>
                      {agency_area.map(({ province, city, district }) => (
                        <p>
                          {province}
                          {city}：
                          {district}
                        </p>
                      ))}
                    </div>
                  ))}
                </div>
              )
            }

          </div>
        ) : (
          <div className={styles.address}>
            <Spin />
          </div>
        )}
        <p className={styles.help}>
          对管辖区域如需设置和调整，请联系快宝驿站负责人员。联系电话：13818443483；QQ：2881505377
        </p>
      </div>
    );
  }
}
